package org.de.maeyer.statistic;
import static java.lang.Double.*;

/**
 * @author Peter De Maeyer
 */
public class DoubleCategory implements Category {
	
	protected final double inclusiveLowerBound;
	
	protected final long count;
	
	public DoubleCategory(double inclusiveLowerBound, long count) {
		this.inclusiveLowerBound = inclusiveLowerBound;
		this.count = count;
	}
	
	@Override
	public boolean contains(Object value) {
		double doubleValue = ((Number) value).doubleValue();
		return doubleValue >= inclusiveLowerBound;
	}
	
	@Override
	public Object getValue() {
		return inclusiveLowerBound;
	}
	
	@Override
	public long getCount() {
		return count;
	}
	
	@Override
	public double getDensity() {
		return 0.;
	}
	
	@Override
	public double getWidth() {
		return POSITIVE_INFINITY;
	}
	
	@Override
	public String toString() {
	    return inclusiveLowerBound + ":" + count;
	}
}
